import {firstTypeObj,projectLevelObj} from "@/assets/js"
import {objToStr} from "@/utils"
export const headerList = [
    {
        prop: "name",
        label: "项目名称",
        type: "text",
        width: "200",
        required: true,
        
    },
    // {
    //     prop: "review_status",
    //     label: "状态",
    //     type: "text",
    //     width: "180",
    //     required: false,
    //     noSort: true,
    // },
    {
        prop: "project_code",
        label: "项目编号",
        type: "text",
        width: "150",
        required: false,
        
    },{
        prop: "project_funds",
        label: "项目经费",
        unit:"(万元)",
        type: "number",
        width: "160",
        required: true,
        
    },{
        prop: "start_time",
        label: "开始日期",
        type: "text",
        width: "150",
        required: false,
        
    },{
        prop: "planned_completion_time",
        label: "终止日期",
        type: "text",
        width: "150",
        required: false,
        
    },{
        prop: "leader_id",
        label: "负责人",
        type: "text",
        width: "130",
        required: true,
        
    },{
        prop: "departments_id",
        label: "所属科室",
        type: "number",
        width: "150",
        required: true,
        
    },{
        prop: "a",
        label: "附件",
        type: "text",
        width: "160",
        required: false,
    },{
        prop: "complete_id",
        label: "完成人",
        type: "text",
        width: "160",
        required: false,
        
    },{
        prop: "project_type",
        label: "项目类别",
        type: "text",
        width: "160",
        required: false,
        
    },{
        prop: "project_source",
        label: "项目来源",
        type: "text",
        width: "180",
        required: false,
        
    },{
        prop: "leader_type",
        label: "负责人类型",
        type: "text",
        width: "150",
        required: true,
        
    },{
        prop: "contact_name",
        label: "联系人名称",
        type: "text",
        width: "150",
        required: false,
        
    },{
        prop: "contact_phone",
        label: "联系人电话",
        type: "number",
        width: "150",
        required: false,
        
    },{
        prop: "project_level",
        label: "项目级别",
        type: "text",
        width: "150",
        required: false,
        
    }
]

export let editForm = {
    id:'',
    name:'',
    project_code:'',
    start_time:'',
    planned_completion_time:'',
    leader_id:'',
    departments_id:'',
    complete_id:'',
    complete_name:"",
    project_type:'',
    project_source:'',
    leader_type:'',
    contact_name:'',
    contact_phone:'',
    project_level:'',
    project_funds:'',
    funds1:'',
    leader_info:{}
    // funds2:'',
    // funds3:'',
    // funds4:'',
    // funds5:'',
}


// firstTypeObj,projectLevelObj
export const dataFn = (data,tableHeade) => {
    let tabStr = ''
    data.forEach((item, index) => {
        let tabRowStr = "";
        tabStr += `<tr>`;
        for (let i = 0; i < tableHeade.length; i++ ) {
            const key = tableHeade[i]
            if (key === 'departments_id') {
                tabRowStr += `<td>${item.department?item.department.name:''}</td>`;
            }else if(key === 'complete_id'){
              tabRowStr += `<td>${objToStr(item.complete_name)}</td>`;
            }else if(key === 'review_status'){
                tabRowStr += `<td>${item.status}${item.review.review_comment ? (':' + item.review.review_comment): ''}</td>`;
            }else if(key === 'leader_id'){
              tabRowStr += `<td>${item.leader_info?item.leader_info.name:''}</td>`;
            }else if(key === 'leader_type'){
              tabRowStr += `<td>${firstTypeObj[item.leader_type] || ''}</td>`;
            }else if(key === 'project_level'){
              tabRowStr += `<td>${projectLevelObj[item.project_level] || ""}</td>`;
            }else {
              tabRowStr += `<td>${item[key] || ''}</td>`;
            }
        }
        tabStr += tabRowStr;
        tabStr += "</tr>";
    });
    return tabStr
}